home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / EditorPanMachine.as < prev    next >
Text File  |  2007-09-27  |  9KB  |  278 lines

  1. class EditorPanMachine extends Library.State
  2. {
  3.    static var DEPTH_VISUAL = 150;
  4.    static var DEPTH_NUMBER = 450;
  5.    static var RECURSIVE_LEVEL_SEARCH = 5;
  6.    static var SCALE_PERCENT = 30;
  7.    static var VISUAL_IN_BOX_X = -225;
  8.    static var VISUAL_IN_BOX_Y = -60;
  9.    function EditorPanMachine(__mcRef)
  10.    {
  11.       super(__mcRef);
  12.       this.oCenterMachine = new EditorCenterPanMachine(this.mcRef.mcState.mcCenter,this);
  13.       this.oCenterMachine.setNumber(1);
  14.       this.oCenterMachine.setRef(this.mcRef.mcState.mcCenter);
  15.       Main.__get__Instance().doAddListener(this);
  16.       this.setState("Idle");
  17.    }
  18.    function doScrollToLeft()
  19.    {
  20.       this.setState("ToLeft");
  21.    }
  22.    function doScrollToRight()
  23.    {
  24.       this.setState("ToRight");
  25.    }
  26.    function setVisualForBox(__sLinkage, __mcBox)
  27.    {
  28.       __mcBox.mcNumber.swapDepths(EditorPanMachine.DEPTH_NUMBER);
  29.       __mcBox.mcData.mcVisual.removeMovieClip();
  30.       __mcBox.mcData.attachMovie(__sLinkage,"mcVisual",EditorPanMachine.DEPTH_VISUAL);
  31.       __mcBox.mcData.mcVisual.gotoAndStop(__mcBox.mcData.mcVisual._totalframes);
  32.       __mcBox.mcData.mcVisual._xscale = EditorPanMachine.SCALE_PERCENT;
  33.       __mcBox.mcData.mcVisual._yscale = EditorPanMachine.SCALE_PERCENT;
  34.       __mcBox.mcData.mcVisual._x = EditorPanMachine.VISUAL_IN_BOX_X;
  35.       __mcBox.mcData.mcVisual._y = EditorPanMachine.VISUAL_IN_BOX_Y;
  36.       this.doRecursiveWorkOn(__mcBox.mcData.mcVisual,EditorPanMachine.RECURSIVE_LEVEL_SEARCH);
  37.    }
  38.    function doRecursiveWorkOn(__mc, __nRecursive)
  39.    {
  40.       if(__mc instanceof MovieClip)
  41.       {
  42.          __mc.stop();
  43.          if(__mc._name.indexOf("Hit") != -1)
  44.          {
  45.             __mc._visible = false;
  46.          }
  47.          else if(__mc._name.indexOf("Ground") != -1)
  48.          {
  49.             __mc._visible = false;
  50.          }
  51.       }
  52.       if(__nRecursive > 0)
  53.       {
  54.          for(var _loc4_ in __mc)
  55.          {
  56.             this.doRecursiveWorkOn(__mc[_loc4_],__nRecursive);
  57.          }
  58.          __nRecursive = __nRecursive - 1;
  59.       }
  60.    }
  61.    function doRefreshVisual()
  62.    {
  63.       this.oCenterMachine.doRefreshVisual();
  64.       this.doLoadStateAction();
  65.    }
  66.    function doDestroy()
  67.    {
  68.       Main.__get__Instance().doRemoveListener(this);
  69.    }
  70.    function get CenterMachine()
  71.    {
  72.       return this.oCenterMachine;
  73.    }
  74.    function doToLeft()
  75.    {
  76.       if(this.isStateComplete())
  77.       {
  78.          this.setState("Idle");
  79.       }
  80.    }
  81.    function doToRight()
  82.    {
  83.       if(this.isStateComplete())
  84.       {
  85.          this.setState("Idle");
  86.       }
  87.    }
  88.    function doLoadStateAction()
  89.    {
  90.       super.doLoadStateAction();
  91.       this.oCenterMachine.setRef(this.mcRef.mcState.mcCenter);
  92.       switch(this.__get__CurrentState())
  93.       {
  94.          case "ToLeft":
  95.             this.doSetUpLeft();
  96.             break;
  97.          case "ToRight":
  98.             this.doSetUpRight();
  99.             break;
  100.          case "Idle":
  101.             this.doSetUpIdle();
  102.             LevelEditor.__get__Instance().onMoveStop();
  103.       }
  104.    }
  105.    function doSetUpLeft()
  106.    {
  107.       var _loc3_ = LevelEditor.__get__Instance().__get__CurrentPanelNumber();
  108.       var _loc9_ = _loc3_ - 1;
  109.       if(_loc9_ <= 0)
  110.       {
  111.          _loc9_ = LevelEditor.PANELS_QTY;
  112.       }
  113.       var _loc10_ = LevelEditor.__get__Instance().getLinkageFor(_loc3_);
  114.       var _loc13_ = LevelEditor.__get__Instance().getLinkageFor(_loc9_);
  115.       var _loc4_ = LevelEditor.__get__Instance().getNumberForPanel(_loc10_);
  116.       var _loc8_ = LevelEditor.__get__Instance().getNumberForPanel(_loc13_);
  117.       if(_loc4_ > LevelEditor.LETTERS.length - 1)
  118.       {
  119.          _loc4_ = 0;
  120.       }
  121.       else if(_loc4_ < 0)
  122.       {
  123.          _loc4_ = LevelEditor.LETTERS.length - 1;
  124.       }
  125.       if(_loc8_ > LevelEditor.LETTERS.length - 1)
  126.       {
  127.          _loc8_ = 0;
  128.       }
  129.       else if(_loc8_ < 0)
  130.       {
  131.          _loc8_ = LevelEditor.LETTERS.length - 1;
  132.       }
  133.       var _loc11_ = LevelEditor.LETTERS[_loc4_];
  134.       var _loc12_ = LevelEditor.LETTERS[_loc8_];
  135.       this.mcRef.mcState.mcBoxRight.mcNumber.txtNumber.text = _loc11_;
  136.       var _loc6_ = LevelEditor.__get__Instance().getLinkageFor(_loc3_);
  137.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxRight);
  138.       var _loc7_ = _loc3_ - 2;
  139.       if(_loc7_ > LevelEditor.PANELS_QTY)
  140.       {
  141.          _loc7_ = 1;
  142.       }
  143.       else if(_loc7_ < 0)
  144.       {
  145.          _loc7_ = LevelEditor.PANELS_QTY;
  146.       }
  147.       this.mcRef.mcState.mcBoxLeft._visible = true;
  148.       this.mcRef.mcState.mcBoxLeft.mcNumber.txtNumber.text = _loc12_;
  149.       _loc6_ = LevelEditor.__get__Instance().getLinkageFor(_loc7_);
  150.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxLeft);
  151.       var _loc5_ = _loc3_ - 1;
  152.       if(_loc5_ > LevelEditor.PANELS_QTY)
  153.       {
  154.          _loc5_ = 1;
  155.       }
  156.       else if(_loc5_ <= 0)
  157.       {
  158.          _loc5_ = LevelEditor.PANELS_QTY;
  159.       }
  160.       this.oCenterMachine.setNumber(_loc5_);
  161.       var _loc2_ = _loc3_ + 1;
  162.       if(_loc2_ > LevelEditor.PANELS_QTY)
  163.       {
  164.          _loc2_ = 1;
  165.       }
  166.       else if(_loc2_ < 0)
  167.       {
  168.          _loc2_ = LevelEditor.PANELS_QTY;
  169.       }
  170.       this.mcRef.mcState.mcBoxRightAbs._visible = true;
  171.       this.mcRef.mcState.mcBoxRightAbs.mcNumber.txtNumber.text = Library.Utils.Tools.getFormatedNumber(_loc2_,2);
  172.       _loc6_ = LevelEditor.__get__Instance().getLinkageFor(_loc2_);
  173.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxRightAbs);
  174.    }
  175.    function doSetUpRight()
  176.    {
  177.       var _loc2_ = LevelEditor.__get__Instance().__get__CurrentPanelNumber();
  178.       var _loc9_ = LevelEditor.__get__Instance().getLinkageFor(_loc2_ + 1);
  179.       var _loc12_ = LevelEditor.__get__Instance().getLinkageFor(_loc2_);
  180.       var _loc4_ = LevelEditor.__get__Instance().getNumberForPanel(_loc9_);
  181.       var _loc7_ = LevelEditor.__get__Instance().getNumberForPanel(_loc12_);
  182.       if(_loc4_ > LevelEditor.LETTERS.length - 1)
  183.       {
  184.          _loc4_ = 0;
  185.       }
  186.       else if(_loc4_ < 0)
  187.       {
  188.          _loc4_ = LevelEditor.LETTERS.length - 1;
  189.       }
  190.       if(_loc7_ > LevelEditor.LETTERS.length - 1)
  191.       {
  192.          _loc7_ = 0;
  193.       }
  194.       else if(_loc7_ < 0)
  195.       {
  196.          _loc7_ = LevelEditor.LETTERS.length - 1;
  197.       }
  198.       var _loc10_ = LevelEditor.LETTERS[_loc4_];
  199.       var _loc11_ = LevelEditor.LETTERS[_loc7_];
  200.       this.mcRef.mcState.mcBoxLeft.mcNumber.txtNumber.text = _loc11_;
  201.       var _loc6_ = LevelEditor.__get__Instance().getLinkageFor(_loc2_);
  202.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxLeft);
  203.       var _loc8_ = _loc2_ + 2;
  204.       if(_loc8_ > LevelEditor.PANELS_QTY)
  205.       {
  206.          _loc8_ = 1;
  207.       }
  208.       else if(_loc8_ < 0)
  209.       {
  210.          _loc8_ = LevelEditor.PANELS_QTY;
  211.       }
  212.       this.mcRef.mcState.mcBoxRight._visible = true;
  213.       this.mcRef.mcState.mcBoxRight.mcNumber.txtNumber.text = _loc10_;
  214.       _loc6_ = LevelEditor.__get__Instance().getLinkageFor(_loc8_);
  215.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxRight);
  216.       var _loc5_ = _loc2_ + 1;
  217.       if(_loc5_ > LevelEditor.PANELS_QTY)
  218.       {
  219.          _loc5_ = 1;
  220.       }
  221.       else if(_loc5_ < 0)
  222.       {
  223.          _loc5_ = LevelEditor.PANELS_QTY;
  224.       }
  225.       this.oCenterMachine.setNumber(_loc5_);
  226.       var _loc3_ = _loc2_ - 1;
  227.       if(_loc3_ > LevelEditor.PANELS_QTY)
  228.       {
  229.          _loc3_ = 1;
  230.       }
  231.       else if(_loc3_ < 0)
  232.       {
  233.          _loc3_ = LevelEditor.PANELS_QTY;
  234.       }
  235.       this.mcRef.mcState.mcBoxLeftAbs._visible = true;
  236.       this.mcRef.mcState.mcBoxLeftAbs.mcNumber.txtNumber.text = Library.Utils.Tools.getFormatedNumber(_loc3_,2);
  237.       _loc6_ = LevelEditor.__get__Instance().getLinkageFor(_loc3_);
  238.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxLeftAbs);
  239.    }
  240.    function doSetUpIdle()
  241.    {
  242.       var _loc2_ = LevelEditor.__get__Instance().__get__CurrentPanelNumber();
  243.       if(_loc2_ > 1)
  244.       {
  245.          this.mcRef.mcState.mcBoxLeft._visible = true;
  246.          this.mcRef.mcState.mcBoxLeft.mcNumber.txtNumber.text = Library.Utils.Tools.getFormatedNumber(_loc2_ - 1,2);
  247.          var _loc4_ = LevelEditor.__get__Instance().getLinkageFor(_loc2_ - 1);
  248.          this.setVisualForBox(_loc4_,this.mcRef.mcState.mcBoxLeft);
  249.       }
  250.       else
  251.       {
  252.          this.mcRef.mcState.mcBoxLeft._visible = false;
  253.       }
  254.       var _loc3_ = _loc2_;
  255.       if(_loc3_ > LevelEditor.PANELS_QTY)
  256.       {
  257.          _loc3_ = 1;
  258.       }
  259.       else if(_loc3_ < 0)
  260.       {
  261.          _loc3_ = LevelEditor.PANELS_QTY;
  262.       }
  263.       this.oCenterMachine.setNumber(_loc3_);
  264.       if(_loc2_ > LevelEditor.PANELS_QTY)
  265.       {
  266.          _loc2_ = 1;
  267.       }
  268.       else if(_loc2_ < 0)
  269.       {
  270.          _loc2_ = LevelEditor.PANELS_QTY;
  271.       }
  272.       this.mcRef.mcState.mcBoxRight._visible = true;
  273.       this.mcRef.mcState.mcBoxRight.mcNumber.txtNumber.text = Library.Utils.Tools.getFormatedNumber(_loc2_ + 1,2);
  274.       _loc4_ = LevelEditor.__get__Instance().getLinkageFor(_loc2_ + 1);
  275.       this.setVisualForBox(_loc4_,this.mcRef.mcState.mcBoxRight);
  276.    }
  277. }
  278.